using System;
using Mbs.Log;
using Mbs.MessageService;
using Mbs.ComponentModel.Container;
using Mbs.ComponentModel.Container.Injection;
using Mbs.ComponentModel.Container.Listner;
using Mbs.ComponentModel.Container.Loader;
using Mbs.Messaging;
using Mbs.Messaging.Imp;
using Mbs.Windows.Elements.Builders;

namespace Mbs.Sample
{
	public class App
    {
        static ILog log = LoggerManager.GetLogger("App");
		[STAThread]
		public static void Main()
		{

            ExceptionService.ExceptionFired = (ex) =>
                {
                    log.Error(ex.Message, ex);
                    MsgBox.ShowError(ex.Message);
                };

            var kernel = new Kernel();
            kernel.ListnerManager.Register(InitializationListner.Instance);
            kernel.ListnerManager.Register(new Mbs.Windows.SmartPartKernelListner());
            kernel.InjectStrategyManager.Register(new Mbs.ComponentModel.Container.Injection.PropertyInjectStragegy());
            kernel.InjectStrategyManager.Register(new Mbs.ComponentModel.Container.Injection.FieldInjectStragegy());

            kernel.LoaderManager.Register(new AssemblyLoader(kernel.GetType().Assembly));
            kernel.LoaderManager.Register(new AssemblyLoader(typeof(ToolStripBuilder).Assembly));
            kernel.LoaderManager.Register(new AssemblyLoader(typeof(Shell.Module.ShellPresenter).Assembly));

            kernel.Register<ILauncher, Launcher>();

            ServiceLocator.Current.Get<ILauncher>().Run();
		}
	}
}